#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
#import <CoreLocation/CoreLocation.h>
#import "Foursquare.h"
#import "FoursquareLogin.h"
#import "FoursquareManagerDelegate.h"
#import "FoursquareVenueCollection.h"
#import "FoursquareVenueAnnotation.h"
#import "FoursquareTipCollection.h"
#import "FoursquareTipAnnotation.h"
#import "MapAppSettings.h"
#import "FoursquareViewDelegate.h"
#import "TouchableWindowDelegate.h"
#import "FoursquareSpecialAnnotation.h"
#import "FoursquareFriendAnnotation.h"

// Constants to identify type of venue update
enum {
	VenueUpdateTypeNormal,
	VenueUpdateTypeView
} VenueUpdateType;

// Constants to identify type of Foursquare action
enum {
	FoursquareActionTypeGeneral,
	FoursquareActionTypeSearch
} FoursquareActionType;

// Constants to identify type of general Foursquare action
enum {
	FoursquareGeneralActionTypeLogin,
	FoursquareGeneralActionTypeVenues,
	FoursquareGeneralActionTypeTips,
	FoursquareGeneralActionTypeSpecials,
	FoursquareGeneralActionTypeFriends,
	FoursquareGeneralActionTypeCancel
} FoursquareGeneralActionType;

//  This Foursquare integration is possible thanks to the Foursquare API by
//  Eric Butler and associates.
//
//  Copyright (C) 2010 Eric Butler <eric@codebutler.com>

/**
 * A FoursquareManager is the main interface providing tools for all
 * Foursquare functionality supported by this application.
 *
 * Code used within this class and the supporting API was written by 
 * Eric Butler and other associates.
 *
 * The supporting API can be found in ./FourSquareAPI folder.
 *
 * @author      Eric Butler
 * @author      James Lin
 * @version     2.3.4 
 * @since       2.0.0
 * @see         UIActionSheetDelegate
 * @see         FoursquareVenueCollectionDelegate
 * @see         FoursquareTipCollectionDelegate
 * @see         FoursquareManagerDelegate
 * @see         FoursquareLoginDelegate
 * @see         TouchableWindowDelegate
 */
@interface FoursquareManager : UIViewController <UIActionSheetDelegate, 
												 UIAlertViewDelegate, 
												 UITextViewDelegate,  
												 FoursquareVenueCollectionDelegate, 
												 FoursquareTipCollectionDelegate, 
												 FoursquareLoginDelegate, 
												 TouchableWindowDelegate> {
	id<FoursquareManagerDelegate> delegate;            // Delegate handling events from manager
	id<FoursquareViewDelegate>    viewDelegate;        // Delegate handling events from view
	FoursquareVenue*              currentVenue;        // Currently referenced venue
	UIButton*                     foursquareButton;    // Button in Foursquare view
	UILabel*                      checkInLabel;        // Label for venue check-in pop-up
	UIAlertView*                  checkInPopup;        // Alert pop-up for venue check-in
	UITextView*                   checkInTextView;     // Text view in venue check-in pop-up
	UIActivityIndicatorView*      foursquareIndicator; // Activity indicator for the view
	//UILabel*                      foursquareLabel;   // Status label for the view
	UITabBar*                     parentTabBar;        // Reference to parent tab bar
	NSUInteger                    searchType;          // Tracks requested search type
	BOOL                          locSelectorModeOn;   // Whether currently selecting a location
	UIToolbar*                    toolbar;             // Toolbar for selecting location
	CLLocationCoordinate2D        searchLocation;      // User-selected location to initiate search
}

/**
 * Retrieve the shared instance of the Foursquare manager.
 *
 * @return  the shared instance of FoursquareManager
 */
+ (FoursquareManager*)sharedFoursquareManager;

/**
 * Set the Foursquare delegate.
 *
 * @param theDelegate  the delegate handling Foursquare events
 */
- (void)setDelegate:(id<FoursquareManagerDelegate>)theDelegate;

/**
 * Display the action sheet for Foursquare functionality given a tab bar.
 *
 * If the user is logged in, an action sheet will animate in using the 
 * tab bar as an origin.
 *
 * If the user is not logged in, a login pop-up will be presented instead.
 *
 * @param tabBar       the tab bar from which the Foursquare action sheet will appear
 * @param theDelegate  the delegate handling Foursquare manager events
 */
- (void)displayFromTabBar:(UITabBar*)tabBar 
			 withDelegate:(id<FoursquareManagerDelegate>)theDelegate;

/**
 * Update the system with a fresh set of venue data.
 *
 * @param theDelegate  the delegate handling Foursquare manager events
 */
- (void)silentUpdateWithDelegate:(id<FoursquareManagerDelegate>)theDelegate;

/**
 * Get the Foursquare view for a given venue.
 *
 * @param theDelegate  the delegate handling Foursquare view events
 * @return             the Foursquare view for the venue
 */
- (UIView*)getFoursquareViewWithDelegate:(id<FoursquareViewDelegate>)theDelegate;

/**
 * Request to check in at a given Foursquare venue.
 *
 * @param venue  the venue at which to check in
 */
- (void)requestCheckInAtVenue:(FoursquareVenue*)venue;

@end
